using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL
{

    /// <summary>
    /// The SpeakLanguageCodeTableManager class is responsible for managing BO.SpeakLanguageCodeTable objects in the system.
    /// </summary>
    [DataObjectAttribute()]
    public class SpeakLanguageCodeTableManager
    {

        #region "Public Methods"

        /// <summary>
        /// Gets a list with all SpeakLanguageCodeTable objects in the database.
        /// </summary>
        /// <returns>A list with all SpeakLanguageCodeTable from the database when the database contains any, or null otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static SpeakLanguageCodeTableList GetList()
        {
            return SpeakLanguageCodeTableDB.GetList();
        }

        /// <summary>
        /// Gets a single SpeakLanguageCodeTable from the database without its data.
        /// </summary>
        /// <param name="speakLanguageCode">The SpeakLanguageCode of the SpeakLanguageCodeTable in the database.</param>
        /// <returns>A SpeakLanguageCodeTable object when the SpeakLanguageCode exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static SpeakLanguageCodeTable GetItem(short speakLanguageCode)
        {
            return GetItem(speakLanguageCode, false);
        }

        /// <summary>
        /// Gets a single SpeakLanguageCodeTable from the database.
        /// </summary>
        /// <param name="speakLanguageCode">The SpeakLanguageCode of the SpeakLanguageCodeTable in the database.</param>
        /// <param name="getSpeakLanguageCodeTableRecords">Determines whether to load all associated SpeakLanguageCodeTable records as well.</param>
        /// <returns>
        /// A SpeakLanguageCodeTable object when the SpeakLanguageCode exists in the database, or <see langword="null"/> otherwise.
        /// </returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static SpeakLanguageCodeTable GetItem(short speakLanguageCode, bool getSpeakLanguageCodeTableRecords)
        {
            SpeakLanguageCodeTable mySpeakLanguageCodeTable = SpeakLanguageCodeTableDB.GetItem(speakLanguageCode);
            return mySpeakLanguageCodeTable;
        }

        /// <summary>
        /// Saves a SpeakLanguageCodeTable in the database.
        /// </summary>
        /// <param name="mySpeakLanguageCodeTable">The SpeakLanguageCodeTable instance to save.</param>
        /// <returns>The new SpeakLanguageCode if the SpeakLanguageCodeTable is new in the database or the existing SpeakLanguageCode when an item was updated.</returns>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
        public static short Save(SpeakLanguageCodeTable mySpeakLanguageCodeTable)
        {
            using (TransactionScope myTransactionScope = new TransactionScope())
            {
                short speakLanguageCodeTableSpeakLanguageCode = (short)SpeakLanguageCodeTableDB.Save(mySpeakLanguageCodeTable);

                //  Assign the SpeakLanguageCodeTable its new (or existing SpeakLanguageCode).
                mySpeakLanguageCodeTable.SpeakLanguageCode = speakLanguageCodeTableSpeakLanguageCode;

                myTransactionScope.Complete();

                return speakLanguageCodeTableSpeakLanguageCode;
            }
        }

        /// <summary>
        /// Deletes a SpeakLanguageCodeTable from the database.
        /// </summary>
        /// <param name="mySpeakLanguageCodeTable">The SpeakLanguageCodeTable instance to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public static bool Delete(SpeakLanguageCodeTable mySpeakLanguageCodeTable)
        {
            return SpeakLanguageCodeTableDB.Delete(mySpeakLanguageCodeTable.SpeakLanguageCode);
        }

        #endregion

    }

}
